package com.cloudcc.mobile.view.customer;

import android.content.Intent;
import android.util.Log;

import com.cloudcc.cloudframe.adapter.CommonAdapter;
import com.cloudcc.cloudframe.bus.EventEngine;
import com.cloudcc.cloudframe.bus.IEventLife;
import com.cloudcc.cloudframe.util.ListUtils;
import com.cloudcc.mobile.adapter.LeadAdapter;
import com.cloudcc.mobile.entity.CustomerEntity;
import com.cloudcc.mobile.entity.LeadEntity;
import com.cloudcc.mobile.event.CustomerEventList.LeadListEvent;
import com.cloudcc.mobile.view.activity.EditorActivity;

/**
 * 签到页面--潜在客户
 * 
 * @author Administrator
 * 
 */

public class LeadListFragment extends BaseCustomerListFragment<LeadEntity>
		implements IEventLife {

	@Override
	public void init() {
		register();
		super.init();
	}

	public void onEventMainThread(LeadListEvent event) {
		boolean shoudClear = mListView.refreshLoadMoreUI(
				ListUtils.isEmpty(event.getData()), event.isError(),
				isFromRefresh(), event.getMessage());
		handlerOnDataReqestFinish(shoudClear, event.getData());
	}

	@Override
	protected void onItemClick(int position, LeadEntity t) {
		Intent intent = new Intent(mContext, EditorActivity.class);
		intent.putExtra("CustomerActivity", "签到拜访 " + "【" + t.getName() + "】");
		Log.d("CustomerActivity", "联系人 " + "【" + t.getName() + "】" + 1);
		intent.putExtra("urlId", t.getId());
		intent.putExtra("reuevantType", "签到拜访");
		intent.putExtra("MapsActivity", location);
		intent.putExtra("key", "0");
		intent.putExtra("from", "map");
		intent.putExtra("name", "联系人 :" + t.getName());
		startActivity(intent);
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		unRegister();
	}

	@Override
	public void register() {
		EventEngine.register(this);
	}

	@Override
	public void unRegister() {
		EventEngine.uregister(this);
	}

	@Override
	protected String getObjApiName() {
		return "Lead";
	}

	@Override
	protected CommonAdapter<LeadEntity> createNewAdapter() {
		return new LeadAdapter(mContext);
	}
}
